/*
 * 
 * 
 * 
 */
package com.hboxs.asl.entity;

import com.fasterxml.jackson.annotation.JsonValue;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.*;

/**
 * Entity - 易问易答支付流水
 */
@Entity
@Table(name = "xx_question_trade")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_question_sequence")
public class QuestionTrade extends BaseEntity {

    private static final long serialVersionUID = -7907800987824149722L;

    /**
     * 支付状态
     */
    public enum PaymentStatus {
        /**
         * 未支付
         */
        unpaid,

        /**
         * 已支付
         */
        paid;

        private static Map<String, QuestionTrade.PaymentStatus> map = new HashMap<>();

        static {
            map.put("未支付", unpaid);
            map.put("已支付", paid);
        }

        public static QuestionTrade.PaymentStatus forValue(String value) {
            return map.get(value);
        }

        @JsonValue
        public String toValue() {
            for (Map.Entry<String, QuestionTrade.PaymentStatus> entry : map.entrySet()) {
                if (entry.getValue() == this) {
                    return entry.getKey();
                }
            }

            return "";
        }

        public static QuestionTrade.PaymentStatus getDefault() {
            return QuestionTrade.PaymentStatus.unpaid;
        }

    }

    /**
     * 支付方式
     */
    public enum PaymentMethod {

        /**
         * 微信支付
         */
        weChat,

        /**
         * 支付宝支付
         */
        alipay;


        private static Map<String, QuestionTrade.PaymentMethod> map = new HashMap<>();

        static {
            map.put("微信支付", weChat);
            map.put("支付宝支付", alipay);
        }

        public static QuestionTrade.PaymentMethod forValue(String value) {
            return map.get(value);
        }

        @JsonValue
        public String toValue() {
            for (Map.Entry<String, QuestionTrade.PaymentMethod> entry : map.entrySet()) {
                if (entry.getValue() == this) {
                    return entry.getKey();
                }
            }
            return "";
        }
    }

    /**
     * 编号
     */
    private String sn;

    /**
     * 易问易答id
     */
    private Long questionId;

    /**
     * 支付状态
     */
    private PaymentStatus paymentStatus;

    /**
     * 支付方式
     */
    private PaymentMethod paymentMethod;

    /**
     * 问题标签
     */
    private String payType;

    /**
     * 价格
     */
    private BigDecimal payPrice;

    /**
     * 是否分享
     */
    private Boolean isShare;

    /**
     * 姓名
     */
    private String name;

    /**
     * 购买者
     */
    private Member buyer;

    /**
     * 提问者id
     */
    private Long memberId;

    /**
     * 提问者姓名
     */
    private String memberName;

    /**
     * 被提问老师id
     */
    private Long teacherId;

    /**
     * 老师姓名
     */
    private String teacherName;

    /**
     * 出生日期
     */
    private Date birth;

    /**
     * 出生时辰
     */
    private String birthHour;

    /**
     * 标题
     */
    private String title;

    /**
     * 问题内容
     */
    private String content;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 回答的内容
     */
    private String answerContent;

    /**
     * 语音url
     */
    private String mediaURL;

    public PaymentStatus getPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(PaymentStatus paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public Long getQuestionId() {
        return questionId;
    }

    public void setQuestionId(Long questionId) {
        this.questionId = questionId;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    public BigDecimal getPayPrice() {
        return payPrice;
    }

    public void setPayPrice(BigDecimal payPrice) {
        this.payPrice = payPrice;
    }

    public Boolean getShare() {
        return isShare;
    }

    public void setShare(Boolean share) {
        isShare = share;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public String getBirthHour() {
        return birthHour;
    }

    public void setBirthHour(String birthHour) {
        this.birthHour = birthHour;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Long getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(Long teacherId) {
        this.teacherId = teacherId;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAnswerContent() {
        return answerContent;
    }

    public void setAnswerContent(String answerContent) {
        this.answerContent = answerContent;
    }

    public String getMediaURL() {
        return mediaURL;
    }

    public void setMediaURL(String mediaURL) {
        this.mediaURL = mediaURL;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Member getBuyer() {
        return buyer;
    }

    public void setBuyer(Member buyer) {
        this.buyer = buyer;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}